﻿namespace Vdc.Grid
{
    using Vdc.Grid.Design;
    using System;
    using System.ComponentModel;

    [TypeConverter(typeof(GridPagingSettingsConverter))]
    public class GridPagingSettings : GridPersistentObject, ICloneable
    {
        public object Clone()
        {
            return new GridPagingSettings { PageSizeSelectorPosition = this.PageSizeSelectorPosition, Position = this.Position, ShowRecordsCount = this.ShowRecordsCount };
        }

        public virtual bool Equals(GridPagingSettings settings)
        {
            return (((this.Position == settings.Position) && (this.PageSizeSelectorPosition == settings.PageSizeSelectorPosition)) && (this.ShowRecordsCount == settings.ShowRecordsCount));
        }

        object ICloneable.Clone()
        {
            return this.Clone();
        }

        [Bindable(true), DefaultValue(1), NotifyParentProperty(true), Description("Gets or sets a value indicating the location where the page size selector will be displayed."), Category("Paging")]
        public GridElementPosition PageSizeSelectorPosition
        {
            get
            {
                object obj2 = base.ViewState["PageSizeSelectorPosition"];
                if (obj2 != null)
                {
                    return (GridElementPosition) obj2;
                }
                return GridElementPosition.Bottom;
            }
            set
            {
                base.ViewState["PageSizeSelectorPosition"] = value;
            }
        }

        [Description("Gets or sets a value indicating the location where the paging buttons will be displayed."), NotifyParentProperty(true), Bindable(true), Category("Paging"), DefaultValue(1)]
        public GridElementPosition Position
        {
            get
            {
                object obj2 = base.ViewState["Position"];
                if (obj2 != null)
                {
                    return (GridElementPosition) obj2;
                }
                return GridElementPosition.Bottom;
            }
            set
            {
                base.ViewState["Position"] = value;
            }
        }

        [DefaultValue(true), Description("Gets or sets a property indicating whether the number of records will be displayed next to the paging buttons."), Category("Paging"), Bindable(true)]
        public bool ShowRecordsCount
        {
            get
            {
                object obj2 = this.ViewState["ShowRecordsCount"];
                if (obj2 != null)
                {
                    return (bool) obj2;
                }
                return true;
            }
            set
            {
                this.ViewState["ShowRecordsCount"] = value;
            }
        }
    }
}

